export const crudOptions = (vm) => {
  return {

    pageOptions: {
      compact: true,
      export: {
        local: true // 本地导出，false为服务端导出
      }
    },
    options: {
      tableType: 'vxe-table',
      rowKey: true, // 必须设置，true or false
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false,
      treeConfig: { // 树形数据配置
        children: 'children',
        hasChild: 'hasChildren',
        expandAll: true
      }
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Retrieve')
        }
      },
      edit: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Update')
        }
      },
      remove: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Delete')
        }
      }
    },
    indexRow: { // 或者直接传true,不显示title，不居中
      title: '序号',
      align: 'center',
      width: 100
    },
    viewOptions: {
      componentType: 'form'
    },
    formOptions: {
      defaultSpan: 24, // 默认的表单 span
      width: '35%'
    },
    columns: [{
      title: '关键词',
      key: 'search',
      show: false,
      disabled: true,
      search: {
        disabled: false
      },
      form: {
        disabled: true,
        component: {
          props: {
            clearable: true
          },
          placeholder: '请输入关键词'
        }
      },
      view: { // 查看对话框组件的单独配置
        disabled: true
      }
    },
    {
      title: '域名',
      key: 'domain',
      show: true,
      width: 400,
      search: {
        disabled: false
      },
      type: 'input',
      form: {
        // editDisabled: true,
        value: '',
        rules: [ // 表单校验规则
          { required: true, message: '名称必填项' }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: '要解析的域名，以.结尾，如test.example.com.'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '状态',
      key: 'status',
      show: true,
      width: 100,
      search: {
        disabled: false
      },
      type: 'input',
      form: {
        // editDisabled: true,
        value: 'ACTIVE',
        rules: [ // 表单校验规则
          { required: true, message: '名称必填项' }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: '状态，默认为ACTIVE(启用)'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '类型',
      key: 'type',
      sortable: true,
      width: 200,
      search: {
        disabled: true
      },
      type: 'select',
      dict: {
        data: [
          { value: 'A', label: 'A -将域名指向IPV4地址', color: 'success' },
          { value: 'CNAME', label: 'CNAME -将域名指向另外一个域名', color: 'warning' },
          { value: 'MX', label: 'MX -将域名指向邮箱服务器地址' },
          { value: 'AAAA', label: 'AAAA -将域名指向IPV6地址' },
          { value: 'TXT', label: 'TXT -设置文本记录' }
        ],
        value: 'value',
        label: 'label'
      },
      form: {
        component: {
          value: 'A', // 默认值
        }
      }
    },
    {
      title: 'TTL(秒)',
      key: 'ttl',
      show: true,
      width: 100,
      search: {
        disabled: true
      },
      type: 'input',
      form: {
        // editDisabled: true,
        value: '300',
        rules: [ // 表单校验规则
          { required: true, message: '名称必填项' }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: 'TTL值，默认为300(秒)'
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '记录值',
      key: 'records',
      show: true,
      width: 650,
      search: {
        disabled: false
      },
      type: 'input',
      validateEvent: true,
      form: {
        // editDisabled: true,
        value: '',
        rules: [ // 表单校验规则
          { required: true, message: '必填项，多个值以,隔开' },
          { pattern: /(\S+,)+\S+|\S+/, message: '多个值以,隔开', trigger: ['blur'] }
        ],
        component: {
          props: {
            clearable: true
          }
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '描述',
      key: 'description',
      show: true,
      width: 650,
      search: {
        disabled: false
      },
      type: 'input',
      form: {
        // editDisabled: true,
        value: '',
        rules: [ // 表单校验规则
          { required: false, message: '请输入描述' }
        ],
        component: {
          props: {
            clearable: true
          },
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    }
    ]
  }
}
